-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add persistent retry queue for failed telemetry events #6572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Implement TelemetryQueue class with FIFO queue structure - Add persistence using VSCode globalState - Integrate queue into TelemetryClient for automatic retry - Process pending events when new events are captured - Add comprehensive test coverage for queue functionality - Limit queue size to 1000 events and max 3 retries per event Fixes #4940
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.
| await this.queue.enqueue(result.data) | ||
|
|
||
| // Process queue asynchronously if not already processing | ||
| if (!this.queue.isProcessingQueue()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? There's a potential race condition here between checking isProcessingQueue() and actually setting the processing state in processQueue(). Multiple simultaneous captures could trigger multiple queue processors.
Could we consider moving the processing state flag setting immediately after the check, or using a more atomic approach?
| }) | ||
|
|
||
| // Check if response indicates success (fetch doesn't throw on HTTP errors) | ||
| if (response === undefined || (response && response.ok !== false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition seems a bit convoluted. Would this be clearer?
| if (response === undefined || (response && response.ok !== false)) { | |
| // Check if response indicates success | |
| if (response && response.ok) { |
The current logic treats undefined as success, which might be confusing for future maintainers.
|
|
||
| export class TelemetryQueue { | ||
| private static readonly QUEUE_KEY = "rooCode.telemetryQueue" | ||
| private static readonly MAX_QUEUE_SIZE = 1000 // Prevent unbounded growth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we consider making these limits configurable? Different deployment scenarios might benefit from different queue sizes and retry counts. Perhaps through extension settings or environment variables?
| * Processes the telemetry queue, sending events to the cloud service | ||
| */ | ||
| private async processQueue(): Promise<void> { | ||
| if (!this.authService.isAuthenticated()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice the queue doesn't automatically process when authentication state changes. If a user was offline and queued events, then comes online and authenticates, they'd need to trigger a new event before the queue processes. Should we consider adding a listener for auth state changes to process the queue?
This PR implements a persistent retry queue for telemetry events that fail to send to Roo Code Cloud, as requested in #4940.
Changes
Key Features
Testing
TelemetryQueue.test.tswith tests for all queue operationsTelemetryClient.queue.test.tsfor integration testingFixes #4940
Important
Introduces a persistent retry queue for telemetry events in
TelemetryClient, ensuring failed events are retried and not lost, with extensive test coverage.TelemetryQueueclass for persistent FIFO queue using VSCodeglobalState.TelemetryClientnow enqueues events instead of sending directly, with automatic retries up to 3 times.TelemetryClientmodified to useTelemetryQueuefor event handling.TelemetryQueue.test.tsfor queue operations.TelemetryClient.queue.test.tsfor integration testing.TelemetryClienttests for queue-based approach.This description was created by
for a629172. You can customize this summary. It will automatically update as commits are pushed.